Method for simulating a mouse device with a keyboard and input system using the same

ABSTRACT

A method for simulating a mouse with a keyboard in a computer system includes detecting whether a key event occurs in a switch matrix of the keyboard of the computer system, determining whether the key event is related to a specific control key when the key event is detected, transforming a location of a switch in which the key event occurs into a pair of coordinates when the key event is not related to the specific control key and is a key-pressed event, calculating a pair of displacements between the latest two pairs of coordinates to obtain a movement data, and transmitting the movement data to a mouse driver of the computer system so that an operating system of the computer system is capable of receiving the movement data by the mouse driver, for controlling movement of a pointer shown on a screen of the computer system.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a method and input device of simulatinga mouse with a keyboard, more particularly, to a method and input deviceof simulating movement of the pointer controlled by the mouse viapressing keys in the keyboard.

2. Description of the Prior Art

Keyboard, mouse, and touchpad are standard input devices equipped by alaptop. Please refer to FIG. 1. FIG. 1 is a schematic diagram of aninput device 10 according to prior art . The input device 10 is used bya laptop and includes a keyboard 100, a mouse 102 and a touchpad 104.The keyboard 100 is a switch matrix composed of multiple switches, and akeyboard controller 106 detects a press of each key and outputs adetection result to an operating system 120 by a keyboard driver 110.The mouse 102 includes components as buttons, a scroll wheel and amotion sensor, etc, and a built-in controller detects a trigger of eachcomponent and outputs a detection result to the operating system 120 bya mouse driver 112. The touchpad 104 is composed of touch componentsarranged in a matrix, and a touchpad controller 108 detects a touch ofeach component and outputs a detection result to the operating system120 by a touchpad driver 114.

In detail, after a user selects English as a language of the keyboard100, when one of the keys is pressed, the keyboard controller 106detects a location of a switch in the switch matrix corresponding to thepressed key, obtains a scan code related to the location of the switchaccording to the keyboard scan code table related to the language of thekeyboard 100, and outputs the scan code to the keyboard driver 110. Akey-pressed event and a key-released event are related to different scancodes respectively. Afterwards, the keyboard driver 110 translates thescan code into a key code which is capable of being processed by theoperating system 120. Since each character or symbol has its relatedscan code, the operating system 120 can obtain the input character orsymbol according to the key code generated by the key driver 110, forcalculating or displaying correctly. In addition, when the user movesthe mouse 102, the built-in controller receives a movement data in X-Yaxes of the mouse 102 and then transmits the movement data to the mousedriver 112. The operating system 120 receives the movement data of themouse 102 by the mouse driver 110 and control movement of a pointershown on a screen of the laptop. When the user controls movement of thepointer by using the touchpad 104 with fingers, the touchpad controller108 receives the movement data in X-Y axes generated by fingers of theuser on the touchpad 104 so that the operating system 120 controlsmovement of the pointer shown on the screen.

The touchpad provides the same function as the mouse and can replace themouse to increase convenience for using the laptop. However, thetouchpad occupies large area on the laptop. For the touchpad settledunder the keyboard, even though the user does not use the touchpad, theuser may touch the touchpad while using the keyboard, which causesincorrect movement of the pointer. Therefore, placement of the touchpadis a key point to develop a miniature and functional laptop.

SUMMARY OF THE INVENTION

It is therefore an objective of the present invention to provide amethod and input device of simulating a mouse for a keyboard.

The present invention discloses a method for simulating a mouse with akeyboard in a computer system. The method comprises detecting whether akey event occurs in a switch matrix of the keyboard of the computersystem; determining whether the key event is related to a specificcontrol key when the key event is detected; transforming a location of aswitch in which the key event occurs into a pair of coordinates when thekey event is not related to the specific control key and is akey-pressed event; calculating a pair of displacements between thelatest two pairs of coordinates to obtain a movement data; andtransmitting the movement data to a mouse driver of the computer systemso that an operating system of the computer system is capable ofreceiving the movement data by the mouse driver, for controllingmovement of a pointer shown on a screen of the computer system.

The present invention further discloses an input device for a computersystem. The input device comprises a keyboard and a keyboard controller.The keyboard controller is coupled to the keyboard and the computersystem and is utilized for detecting whether a key event occurs in aswitch matrix of the keyboard; determining whether the key event isrelated to a specific control key when the key event is detected;transforming a location of a switch in which the key event occurs into apair of coordinates when the key event is not related to the specificcontrol key and is a key-pressed event; calculating a pair ofdisplacements between the latest two pairs of coordinates to obtain amovement data; and transmitting the movement data to a mouse driver ofthe computer system so that an operating system of the computer systemis capable of receiving the movement data by the mouse driver, forcontrolling movement of a pointer shown on a screen of the computersystem.

These and other objectives of the present invention will no doubt becomeobvious to those of ordinary skill in the art after reading thefollowing detailed description of the preferred embodiment that isillustrated in the various figures and drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram of an input device according to the priorart.

FIG. 2 is a schematic diagram of an input device according to anembodiment of the present invention.

FIG. 3 is a layout diagram of the keyboard in FIG. 2.

FIG. 4 is a flowchart of a process according to an embodiment of thepresent invention.

DETAILED DESCRIPTION

Please refer to FIG. 2. FIG. 2 is a schematic diagram of an input device20 according to an embodiment of the present invention. The input device20 is used in a computer and includes a keyboard 200 and a mouse 202.The mouse 202 is removable from the computer, and the keyboard 200 iscapable of simulating an operation of the mouse 202. Therefore, theinput device 20 without a touchpad used for replacing the mouse 202 isable to miniaturize dimensions of the computer.

In the input device 20, the keyboard 200 is composed of a switch matrix,and a keyboard controller 204 transforms a signal generated by each keypressed and released in the keyboard 200 into a scan code according to akeyboard scan code table and outputs the scan code to a keyboard driver206. The keyboard driver 206 is used for driving the keyboard controller204 and translating the scan code into a key code, which is capable ofbeing processed by an operating system 210 for controlling the computer.The abovementioned is the operation of a general input function of thekeyboard 200 and is well known to those skilled in the art. In addition,the mouse 202 includes components as buttons, a scroll wheel and amotion sensor, etc., and a built-in controller detects a trigger statusof each component. A mouse driver 208 is used for driving the mouse 202.When the mouse 202 moves, the built-in controller of the mouse 202outputs a movement data in X and Y axes to the mouse driver 208, andthereby the operating system 210 controls movement of a pointer shown ona screen of the computer according to the movement data in X and Y axesof the mouse 202.

Note that, the keyboard controller 204 is further used for transforminga location of a switch of each key of the keyboard 200 within apredefined operating area into a pair of coordinates in X and Y axes,which represents a location on physical plane. Abovementionedtransformation can be obtained by a table recording the location of eachswitch and the corresponding XY coordinates. However, this should not beconstrued as a limit to the present invention. After receiving two pairsof XY coordinates corresponding to two keys pressed continuously, thekeyboard controller 204 calculates a pair of XY displacements betweenthe two pairs of XY coordinates to obtain the movement data in X and Yaxes, and outputs the movement data to the mouse driver 208. The formatused by the movement data outputted from the keyboard controller 204 isthe same as that used by the movement data outputted from the mouse 202.The mouse driver 208 only needs to transmit the received movement datato the operating system 210 so that the operating system 210 controlsmovement of the pointer on the screen according to the movement data,whether the movement data is generated from the mouse 202 or thekeyboard controller 204.

In order to simulate a mouse by the keyboard 200, one key of thekeyboard 200 can be set as a function key for activating anddeactivating a mouse simulation. When the user slides keys of thekeyboard 200 as the touchpad operation, the keyboard controller 204outputs the movement data in X and Y axes to the mouse driver 208 sothat the operating system 210 controls movement of the pointer on thescreen. Please refer to FIG. 3. FIG. 3 is a layout diagram of thekeyboard 200. The operating area used for simulating the mouse has arange represented by bold lines and includes keys with uniform size forsliding keys more fluently to avoid the keyboard controller 204 fromgenerating the movement data with more inaccuracy.

For example, if the pointer shown on the screen is located at a point Aand the mouse simulation function of the keyboard 200 is activated. When‘X’, ‘D’, ‘F’, ‘R’ and ‘T’ keys of the keyboard 200 are pressedsequentially, the keyboard controller 204 transforms positions ofswitches of ‘X’, ‘D’, ‘F’, ‘R’ and ‘T’ keys sequentially into pairs ofXY coordinates as (2,2), (3,2), (4,3) and (4,4), and thereby generatespairs of XY displacements (1,0), (1,1) and (0,1) as the movement data.After the abovementioned movement data are processed by the operatingsystem 210, the pointer is controlled to move from the point A to right,to right upward and further upward to a point B. The keyboard controller204 calculates the movement data according to two pairs of XYcoordinates received continuously. Therefore, the user is able to onlypress two keys corresponding to a starting position and an endingposition of the pointer sequentially, and the pointer is directly movedto the ending position. From the previous example, the pointer is movedfrom the point A to the point B when ‘X’ and ‘T’ keys are pressedsequentially.

Further, in order to fully simulate the mouse, the keyboard 200 mayinclude keys for simulating mouse control keys, i.e. the left, middleand right buttons of the mouse 202. For example, in the operating areashown in FIG. 3, the left Alt key may be used for simulating the leftbutton of the mouse, the space bar may be used for simulating the middlebutton of the mouse, and the right Alt key may be used for simulatingthe right button of the mouse. When the keyboard controller 204 detectsa press on the keys simulating the left, middle or right button of themouse 202, the keyboard controller 204 transmits the related controldata to the mouse driver 208, and therefore, the operating system 210 iscapable of performing related operations.

Please refer to FIG. 4 for detailed operations of the keyboardcontroller 204 to control the keyboard 200 for simulating the mouse.FIG. 4 is a flowchart of a process 40 according to an embodiment of thepresent invention. The process 40 is the process used by the keyboardcontroller 204 and includes following steps:

Step 400: Start.

Step 402: Detect whether a key event occurs in a switch matrix of thekeyboard 200. If yes, perform the step 404; otherwise, perform the step402.

Step 404: Determine whether the key event is related to a specificcontrol key used by the operating system 210. If yes, perform the step406; otherwise, perform the step 408.

Step 406: Transmit a scan code related to the specific control key tothe operating system 210.

Step 408: Determine whether the key event is related to a mouse controlkey. If yes, perform the step 410; otherwise, perform the step 412.

Step 410: Record a mouse state value for the key event and return to thestep 402.

Step 412: Determine whether the key event is a key-pressed event. Ifyes, perform the step 414; otherwise, perform the step 402.

Step 414: Transform a location of a switch in which the key event occursinto a pair of coordinates.

Step 416: Calculate a pair of displacements between the latest two pairsof coordinates to obtain a movement data.

Step 418: Transmit the mouse state value and the movement data to themouse driver 208.

Step 420: End.

The keyboard controller 204 scans all switches in the switch matrix ofthe keyboard 200 periodically. For example, a keyboard controller in ageneral PS/2 standard keyboard uses a frequency around 30 KHz to scanall switches to detect whether a key event occurs in the switch matrixof the keyboard 200. The key event may be a key-pressed event or akey-released event related to the on/off state of the switch of the key.

The step 404 to the step 420 are performed when the mouse simulationactivated by the keyboard 200. When detecting a key event, the keyboardcontroller 204 determines whether the key event is related to a controlkey used by the operating system 210, e.g. Shift key or Esc key,according to the step 404. When the key event is related to the controlkey, i.e. the pressed or released key is the control key, the keyboardcontroller 204 transmits a scan code related to the control key to theoperating system 210 according to the step 406. In other words, when themouse simulation activated by the keyboard 200, the control key used bythe operating system 210 is still utilized for performing the originalassignment and not for the mouse simulation. After transmitting the scancode, the keyboard controller 204 continuously detects whether a nextkey event occurs.

When the key event is not related to the control key used by theoperating system 210, i.e. the pressed or released key is not thecontrol key, the keyboard controller 204 further determines whether thekey event is related to the mouse control key, i.e. whether the pressedor released key is set for the mouse control keys according to the step408. The mouse control keys are keys that simulate the left, middle andright buttons of the mouse. When the key event is related to the mousecontrol key, the keyboard controller 204 records a mouse state value forthe key event according to the step 410. The mouse state value iscapable of representing the key pressed or released, e.g. represent by‘0’ or ‘1’. After recording the mouse state value, the keyboardcontroller 204 continuously detects whether a next key event occurs.Abovementioned step 404 and step 408 can be summed up to a step ofdetermining whether the key event is related to a specific control key.

Further, when the key event is neither related to the control key usedby the operating system 210 nor related to any of the mouse controlkeys, which means that the pressed or released key is located in theoperating area for simulating movement of the mouse in the keyboard 200,the keyboard controller 204 determines whether the key event is thekey-pressed event according to the step 412. When the key event is thekey-pressed event, the keyboard controller 204 performs the step 414 tothe step 418. When the key event is not the key-pressed event and is thekey-released event, the keyboard controller 204 returns to perform thestep 402 for detecting next key event.

The step 414 to the step 418 are main steps of the keyboard 200 tosimulate the mouse. The keyboard controller 204 transforms the positionof the switch in which the key event occurs into a pair of XYcoordinates. Take FIG. 3 for an example. If the position of the switchof ‘F’ key is (Column 3, Row 12), when ‘F’ key is pressed, ‘F’ key sendsa voltage signal to the keyboard controller 204 so that the keyboardcontroller knows that the pressed switch is in the position (Column 3,Row 12) according to the voltage signal and transforms the position(Column 3, Row 12) into XY coordinates (4, 6). Please note that, thekeyboard controller 204 can not recognize characters or functionsrepresented by the pressed or released key. Instead, the keyboardcontroller 204 recognizes each key by the position of the correspondingswitch in the circuit, and the position of the switch is not related tothe position of physical key recognized by the user. For this reason,the keyboard controller 204 performs a coordinate transformation of thestep 414 for receiving related coordinates continuously for simulatingmovement of the mouse or the finger tracking on the touchpad.

After receiving coordinates (x, y) related to the pressed key, thekeyboard controller 204 calculates a pair of XY displacements of thelatest two pairs of XY coordinates, i.e. (x, y) and (x0, y0) previouslyreceived, to obtain (x-x0, y-y0) as a movement data, and transmits themovement data to the mouse driver 208. Please note that, the format usedby the movement data transmitted from the keyboard controller 204 is thesame as that used by the movement data transmitted from the mouse driver208. Take a mouse complying with PS/2 standard for an example, movementdata transmitted to the mouse driver 208 includes 1 byte of an X-axisdisplacement, 1 byte of a Y-axis displacement and 3 bits of mouse statevalue of the left, middle and right buttons of the mouse. Thus, thekeyboard controller 204 transmits displacement data (x-x0) and (y-y0) tothe mouse driver 208.

According to the step 418, except transmitting the movement data, thekeyboard controller 204 transmits the mouse state values to the mousedriver 208 as well. Therefore, via the mouse driver 208, the operatingsystem 210 receives the mouse state values and the movement data thatare similar to those outputted by the mouse 202, and moves the pointershown on the screen of the computer to a corresponding position andperforms related operations of the mouse control key. Note that, thestep 404 to the step 420 of the process 40 are performed when the mousesimulation is activated. When the process 40 is being performed and theuser operates related function keys to stop the mouse simulation, theprocess 40 is stopped immediately, and the keyboard 200 and the keyboardcontroller 204 return to perform the general character input function asin prior art.

As a well-known in the art, the sensitivity of the mouse is able to beadjusted by the operating system of the computer according torequirement of the user, to response the velocity of pointer movement.Note that, the important points of the input device 20 in FIG. 2 and theprocess 40 in FIG. 4 are using the keyboard controller to transform thekey events generated continuously into coordinates to generate themovement data outputted to the mouse driver. The operations of the mousedriver and the operating system are the same as that in prior art. Thus,the velocity of pointer movement that is controlled by using the process40 is able to be adjusted as prior art by the operating system 210.

With the process and computer system according to the present invention,the keyboard of the computer is capable of simulating the mouse and thetouchpad is no more required in the computer, which brings greatadvantages for the computer miniaturization.

Those skilled in the art will readily observe that numerousmodifications and alterations of the device and method may be made whileretaining the teachings of the invention.

1. A method for simulating a mouse with a keyboard in a computer system,the method comprising: detecting whether a key event occurs in a switchmatrix of the keyboard of the computer system; determining whether thekey event is related to a specific control key when the key event isdetected; transforming a location of a switch in which the key eventoccurs into a pair of coordinates when the key event is not related tothe specific control key and is a key-pressed event; calculating a pairof displacements between the latest two pairs of coordinates to obtain amovement data; and transmitting the movement data to a mouse driver ofthe computer system so that an operating system of the computer systemis capable of receiving the movement data by the mouse driver, forcontrolling movement of a pointer shown on a screen of the computersystem.
 2. The method of claim 1, wherein the specific control key is acontrol key used by the operating system.
 3. The method of claim 1,wherein the specific control key is a mouse control key.
 4. The methodof claim 1 further comprising: transmitting a scan code related to thespecific control key to the operating system when the key event isrelated to the specific control key and the specific control key is usedby the operating system.
 5. The method of claim 1 further comprising:recording a mouse state value for the key event when the key event isrelated to the specific control key and the specific control key is usedfor a mouse control key.
 6. The method of claim 5 further comprising:transmitting the mouse state value to the mouse driver whiletransmitting the movement data to the mouse driver.
 7. An input devicefor a computer system comprising: a keyboard; and a keyboard controller,coupled to the keyboard and the computer system, for: detecting whethera key event occurs in a switch matrix of the keyboard; determiningwhether the key event is related to a specific control key when the keyevent is detected; transforming a location of a switch in which the keyevent occurs into a pair of coordinates when the key event is notrelated to the specific control key and is a key-pressed event;calculating a pair of displacements between the latest two pairs ofcoordinates to obtain a movement data; and transmitting the movementdata to a mouse driver of the computer system so that an operatingsystem of the computer system is capable of receiving the movement databy the mouse driver, for controlling movement of a pointer shown on ascreen of the computer system.
 8. The input device of claim 7, whereinthe specific control key is a control key used by the operating system.9. The input device of claim 7, wherein the specific control key is amouse control key.
 10. The input device of claim 7, wherein the keyboardcontroller is utilized for transmitting a scan code related to thespecific control key to the operating system when the key event isrelated to the specific control key and the specific control key is usedby the operating system.
 11. The input device of claim 7, wherein thekeyboard controller is utilized for recording a mouse state value forthe key event when the key event is related to the specific control keyand the specific control key is used for a mouse control key.
 12. Theinput device of claim 11, wherein the keyboard controller is utilizedfor transmitting the mouse state value to the mouse driver whiletransmitting the movement data to the mouse driver.